package com.lxy.phonebook.config;//当前类是一个配置类

import com.lxy.phonebook.interceptor.SysInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebAppConfigurer extends WebMvcConfigurerAdapter {

    //用来配置那些请求的URL被拦截，那些不拦截
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] patterns = new String[]{"/Admin/login", "/* .html", "/image"};
        registry.addInterceptor(new SysInterceptor())
                .addPathPatterns("/**").excludePathPatterns(patterns);
    }
}